<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>Đại học thái nguyên</title>
		<link rel="stylesheet" type="text/css" href="css/style.css"/>
		<link rel="stylesheet" type="text/css" href="css/nivo-slider.css"/>
		<script type="text/javascript" src="js/jquery-1.4.2.js"></script>
		<script type="text/javascript" src="js/jquery.nivo.slider.js"></script>
		<script type="text/javascript">
			$(document).ready(function(){
				var tabActived = $("#tabbed-menu .tabs li.actived");	
				var tabActivedClasses = tabActived.attr("class");
				var ulTabbeds = $("#tabbed-menu .content ul");

				for(var i = 0; i< ulTabbeds.length; i++){
				
					var ulClass = ulTabbeds.eq(i).attr("class");
					if(tabActivedClasses.indexOf(ulClass) != -1){
						ulTabbeds.eq(i).css("display","block");
						break;
					}
				}
				
				$("#tabbed-menu .tabs li").click(function(){
						
							if($(this).attr("class").indexOf("actived") == -1){
								$("#tabbed-menu .tabs li.actived").removeClass("actived");
								$(this).addClass("actived");
								$("#tabbed-menu .content ul").fadeOut(0);
								for(var i = 0; i< ulTabbeds.length; i++){
									var ulClass = ulTabbeds.eq(i).attr("class");
									if($(this).attr("class").indexOf(ulClass) != -1){
										ulTabbeds.eq(i).fadeIn(0);
										break;
									}
								}
							}
				}); 
				$('#slider').nivoSlider();
				$("#langvi").click(function(){
					$.ajax({type:"GET",
							url:"lang.php",
							data:"lang=0",
							success: function(data){
								alert(data);						
								//window.location.reload();
								
							}
					});
					//return false;
				});

				$("#langen").click(function(){
					$.ajax({type:"GET",
							url:"lang.php",
							data:"lang=1",
							success: function(data){
								alert(data);
								
								//window.location.reload();
								
							}
					});
					//return false;
				});

				//script chạy menu
				$("#h-menu li").hover(function(){
					$(this).children("ul").fadeIn(400);
				},function(){
					$(this).children("ul").fadeOut(400);
				});
			});
			function  showlogin()
			{
				var content="";
				$("#login").css("height","180px");
				 content=" <form name='frmlogin' action='' method='post'> <div class='field'>User Name <span><input type='text'  value=''"+ "name='username'></span>  </div>"+
"<div class='field' style=''>Password <span><input type='password'  value='' name='password'></span></div><center><input type='submit' value='đăng nhập' name='login'/></center></form>";
				$("#showlogin").html(content);
				$("#showlogin").css("border-bottom","solid 1px #FFFFFF");
			}
		</script>
        <style type="text/css">
		.field{
		width:100%;
		float:left;
		margin-top:5px;
		}
		.field span input
		{
			float:right;
			width:100px;
	    }
		</style>
	</head>
<body>
	<?php
	if(isset($_POST["login"]))
{
$username=$_POST["username"];
$password=$_POST["password"];
$st="select StudentID,StudentName from tblstudent where StudentCode='$username' and StudentPass=md5('$password')";
$kq=mysql_query($st);
$nr=mysql_num_rows($kq);
$row=mysql_fetch_assoc($kq);
if($nr>0)
{			
            $_SESSION["UserIDst"] = $row['StudentID'];	
			$_SESSION["User"] =$row['StudentName'];
}
}
 $st1="select * from weblink";
$kq1=mysql_query($st1);
?>
	<div id="header">
			<div id="h-top">
				<div id="logo"><a href="<?php echo ROOT_PATH;?>">
					<img src="images/logo.png" alt="logo" width="186" height="50"/></a>
				</div>
  				<ul id="h-menu">
  					<?php
					// lấy menu gốc
					$sqlRootMenus =sprintf("select * from tblmenu where parent_id = 0 order by tblmenu.order");
					$rootMenusResult= mysql_query($sqlRootMenus) or die(mysql_error());
					//cấp 1
					$i = 0;
					$arrRootMenus = array();
				 	while($row = mysql_fetch_object($rootMenusResult)){
				 		// luuw lại menu gốc cho footer;
				 		$arrRootMenus[] = $row;
				 		$i++;
						echo "<li ".(($i==mysql_num_rows($rootMenusResult)) ? "class='last'" : ""). "><a href='".ROOT_PATH.(($row->url =="") ? "/m/". $row->id : $row->url)."'>".(($lang == 0) ? $row->vi_name : $row->en_name)."</a>";
						$sqlChildMenus1 =sprintf("select * from tblmenu where parent_id = %s order by tblmenu.order", $row->id);
						$childMenusResult1= mysql_query($sqlChildMenus1) or die(mysql_error());
						if(mysql_num_rows($childMenusResult1) >0){
							echo "<ul>";
							//cấp 2
							while($row1 = mysql_fetch_object($childMenusResult1)){
								echo "<li><a href='".ROOT_PATH. (($row1->url =="") ? "/m/". $row1->id : $row1->url)."'>".(($lang == 0) ? $row1->vi_name : $row1->en_name)."</a>";
								$sqlChildMenus2 =sprintf("select * from tblmenu where parent_id = %s order by tblmenu.order", $row1->id);
								$childMenusResult2= mysql_query($sqlChildMenus2) or die(mysql_error());
								if(mysql_num_rows($childMenusResult2) >0){
									echo "<ul>";
									//cấp 3
									while($row2 = mysql_fetch_object($childMenusResult2)){
										echo "<li><a href='".ROOT_PATH.(($row2->url =="") ? "/m/". $row2->id : $row2->url)."'>".(($lang == 0) ? $row2->vi_name : $row2->en_name)."</a></li>";
									}
									echo "</ul>";
								}
								echo "</li>";
							}
							echo "</ul>";
						}
						echo "</li>";
					}
				?>
				</ul>
				
			</div><!-- end of sub.htmlh-top -->
			<div id="slider">
				<?php
					$sqlImages = "select link from tblhome_image";
					$rsImages = mysql_query($sqlImages) or die(mysql_error());
					while($image = mysql_fetch_object($rsImages)){
						echo "<img src='".$image->link."' alt=''/>"; 
					} 
				?>
			</div><!-- end of sub.htmlslide -->
			<div id="search">
					<div>
						<a href="" id="langen">
							<img src="images/en.png" alt="English"/>
						</a>
						<a href="" id="langvi">
							<img src="images/vi.png" alt="Vietnamese"/>
						</a>
					</div>
					<div>
						<form name="frmSearch" action="<?php echo ROOT_PATH;?>/search" method="post">
							<input type="text" name="key" id="txtKeyWord" size="20"/>
							<input type="submit" id="btnSearch" value=""/>
						</form>
					</div>
							
				</div>
				<div id="login">
					<div class="l-top">

							<a href="#" onclick="showlogin()">Login</a>
							<a href="index.html">Site Map</a>
							<a href="#"><img src="<?php echo ROOT_PATH?>/images/mail.jpg" alt="Mail"/></a>
					</div>
                     <div id="showlogin">
						 <span style="height:30px;color:#00C;font-size:14px"><?php if($_SESSION["UserIDst"]!="") echo "<a href='".ROOT_PATH."/tnu/editinfo.php'>".$_SESSION["User"]."</a>"."  "."<a href='".ROOT_PATH."/tnu/logout.php'>đăng xuất</a>"; ?> </span>
                        
                     </div>

						<div class="l-bottom">
							<div class="a1">
								<a href="#"><?php echo ($lang==0)?"Liên kết website":"Website links";?></a>
							
							</div>
							<div class="a2">
							  <select onChange="window.location=this.value">
                              <option>--Website liên kết--</option>
                             <?php
							  	
							  while($rowweb=mysql_fetch_array($kq1))
							 {
                              echo "<option value='".$rowweb["url"]."'>" .$rowweb["name"]."</option>";
							 }
							?>
                              </select>
							 
							</div>	

					
					
				</div>
			</div>
			
		</div>
	<div id="all">
		
		<div id="main">
			<div id="m-left">
			</div>
			<div id="m-mid">
				<div id="news" class="box">
					<div class="b-title">Tin tức</div>
					<div class="b-container">
						<ul>
							<?php
							//lấy các tin tức nổi bật
							if($lang == 0){
								$sqlFeaturedArticle = "Select id, vi_title as title, vi_summary as summary, created_date From tblarticle where featured = 1 AND published = 1 ORDER BY created_date DESC LIMIT 5";
							}else{
								$sqlFeaturedArticle = "Select id, en_title as title, vi_summary as summary, created_date From tblarticle where featured = 1 AND published = 1 ORDER BY created_date DESC LIMIT 5";
							}
							$rsFeaturedArticle = mysql_query($sqlFeaturedArticle) or die(mysql_error());
							while ($featuredArticle = mysql_fetch_object($rsFeaturedArticle)){
							?>
							<li>
								<a href="<?php echo ROOT_PATH;?>/view/<?php echo $featuredArticle->id;?>"><?php echo $featuredArticle->title;?></a>
								<p class="summary">
									<?php echo $featuredArticle->summary."...";?>
								</p>
								<p class="readmore">
									<a href="<?php echo ROOT_PATH;?>/view/<?php echo $featuredArticle->id;?>">Xem tiếp</a>
								</p>
							</li>
							<?php }?>
							
							
						</ul>
					</div>
				</div><!-- end of sub.htmlnews -->
				<?php
					//lấy dữ liệu đổ vào tab
					if($lang ==0){
						$sqlMenu2Tabbed = "Select id,vi_name as name, url from tblmenu where featured = 1 LIMIT 3";
					}else{
						$sqlMenu2Tabbed = "Select id,en_name as name, url from tblmenu where featured = 1 LIMIT 3";
					}
					$rsMenu2Tabbed = mysql_query($sqlMenu2Tabbed) or die(mysql_error());
				
					 
				?>
				<div id="tabbed-menu">
					<div class="tabs">
						<ul>
							<?php
							$i=0;
							$arrTabbedMenus = array(); 
							while($tabbedMenu = mysql_fetch_object($rsMenu2Tabbed)){
								$arrTabbedMenus[] = $tabbedMenu;
								echo "<li class='tab".$tabbedMenu->id.(($i==0)?" actived":"")."'>".$tabbedMenu->name."</li>";
								$i++;
							}
							?>
						</ul>
					</div>
					<div class="content box">
					<?php
					foreach($arrTabbedMenus as $tabbedMenu){
						if($lang ==0){
							$sqlTabConent = "Select id,vi_name as name, url from tblmenu where parent_id =".$tabbedMenu->id." LIMIT 5";
						}else{
							$sqlTabConent = "Select id,en_name as name, url from tblmenu where parent_id =".$tabbedMenu->id." LIMIT 5";
						}
//						echo $sqlTabConent;
						$rsTabConent = mysql_query($sqlTabConent) or die(mysql_error());
					?>
						<ul class="tab<?php echo $tabbedMenu->id;?>">
					<?php 
						while($tabContent = mysql_fetch_object($rsTabConent)){
//							echo $tabContent->url;
							if($tabContent->url!="" && strstr($tabContent->url, "view")){
								
								$article_id = substr($tabContent->url, strrpos($tabContent->url,"/") + 1);
								if($lang ==0){
									$sqlArticle = "Select id,vi_title as title, vi_summary as summary from tblarticle where id =".$article_id;
								}else{
									$sqlArticle = "Select id,en_title as title, en_summary as summary from tblarticle where id =".$article_id;
								}
								$article = mysql_fetch_object(mysql_query($sqlArticle)) or die(mysql_error());
					?>
							<li>	
								<a href="<?php echo ROOT_PATH."/view/".$article->id;?>"><?php echo $article->title;?></a>
								<p class="summary">
									<?php echo $article->summary?>
								</p>
								<p class="readmore">
									<a href="<?php echo ROOT_PATH."/view/".$article->id;?>">Xem tiếp</a>
								</p>
							</li>
					<?php
							}
						}
					?>
						</ul>
					<?php
					}
					?>
						
							
							
					</div>
				</div>
			</div>
			<div id="m-right">
				
			</div>
			<div class="clear-fix"></div>
		</div>
		<div id="footer">
			<div id="f-menu">
				<ul>
					<?php foreach($arrRootMenus as $rootMenu){
						if($lang ==0){
							echo "<li><a href='".ROOT_PATH.(($rootMenu->url=="")? "/m/".$rootMenu->id: $rootMenu->url)."'>".$rootMenu->vi_name."</a></li>";
						}else{
							echo "<li><a href='".ROOT_PATH.(($rootMenu->url=="")? "/m/".$rootMenu->id: $rootMenu->url)."'>".$rootMenu->en_name."</a></li>";
						}
					}?>
				</ul>
			</div>
			<div id="copyright">
				<?php if($lang==0){?>
					Bản quyền thuộc về khoa quốc tế đại học Thái Nguyên<br/>
				<?php }else{?>
					Copyright by Internation Department of Thainguyen University
				<?php }?>
				Design &copy; 2011 <a href="http://idgit.com.vn">Idea Development Group</a>
			</div>
			
		</div>
	</div>
</body>
</html>
